"""
[1, 2, 3, 4, 5]
1 2 3 4 5
1
5
[1, 2, 3]
[3, 4, 5]
[1, 3, 5]
"""
list1=[]
list2={}
list3=[1,2,3,4,5]
print(list3)
for i in list3:list1=[]
list2={}
list3=[1,2,3,4,5]
print(list3)
for i in list3:
    print(i,end=' ')
print()
print(list3[0])
print(list3[-1])
print(list3[:3])#0可省略
print(list3[2:])
print(list3[::2])

list3.append(6)
print(list3)
list3.insert(0,0)
print(list3)
list3.extend([7,8])
print(list3)

#print(list3[100])#IndexError: list index out of range 下标越界
#print(list3[100])#IndexError: list index out of range 下标越界
list4=[11,5,33,22,66,2,9]
#list4.sort()
#print(list4)
#list4.sort(reverse=True)
#print(list4)
#list4.reverse()#reverse需和sort一起使用
#print(list4)
#sorted(list4)
list4_new=sorted(list4)#生成新列表 不改变原列表
print(list4)
print(list4_new)
list3.pop()
print(list3)
list3.remove(5)
print(list3)
list3.clear()
print(list3)
list4[0]=100
list5=[i for i in list4 if i%2==0]
print(list5)

#元组
tuple1=()
tuple2=tuple()
tuple3=(1,2,3,4,5)
print(tuple3)
for i in tuple3:
    print(i,end=' ')
print(tuple3[0])
print(tuple3[-1])
print(tuple3[1::4])
print(tuple3[::3])
print(tuple3[::2])

set1=set([1,2,3,4,5,3,7,4,1])
print(set1)
set1.pop()
print(set1)
#set1.remove(77)
set1.remove(5)
print(set1)
set1.discard(77)
print(set1)
set1.clear()
print(set1)

dict0={}
dict1=dict()
dict2={'name':'张三','age':'18','sex':'男'}
print(dict2)
print(dict2['name'])
print(dict2['age'])
for key,value in dict2.items():
    print(key,value)
    for key in dict2.keys():
        print(key)
#print(dict2.get['name'])
print(dict2.get('id','没有相关数据'))
print(dict2.get('id2'))
dict2['id']=100
print(dict2)
dict2['id']=101
print(dict2)
dict2.update({'id':102,'sex':'女'})
print(dict2)
dict2.update({'phone':'12345678901','email':'11@qq.com'})
dict2.pop('id')
print(dict2)
item=dict2.popitem()
print(item)
print(type(item))
dict2.clear()
print(dict2)
print(dict2)
dict2.clear()
print(dict2)

list8=[1,2,3]
list9=[4,5,6]
print(list8+list9)
print(list8*3)

tuple4=(1,2,3)
print(tuple4*3)
print(tuple4+tuple4)
touple5=tuple4*3
print(touple5)
print(1 in list8)
print(111 in list8)
print(1 not in list8)
print(111 not in list8)
